package leetcode_day._2022._202203._2131;

/**
 * @author yzh
 * @version 1.0
 * @date 2022/3/22 20:15
 * 如果相邻两个颜色均相同则删除当前颜色
 * 算法：脑筋急转弯
 */
public class _22_2038 {

    public boolean winnerOfGame(String colors) {
        int sum = 0;
        for (int i = 1; i < colors.length() - 1; i++) {
            String tmp = colors.substring(i - 1, i + 2);
            if ("AAA".equals(tmp)) ++sum;
            else if ("BBB".equals(tmp)) --sum;
        }
        return sum > 0;
    }
}
